<?php
my_component_load('xl_builder' , false);
my_component_load('testing' , false);
my_component_load('paging' , false);  
my_component_load('pr_yearly_income_exception' );
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$karyawan_id=$kid= isset( $_GET['karyawan_id'] ) ? $_GET['karyawan_id']:  0;
$yearly_income_id= isset( $_GET['yearly_income_id'] ) ? $_GET['yearly_income_id']:  get_latest_yearly_income();
$komponen_id= isset( $_GET['komponen_id'] ) ? $_GET['komponen_id']:  0;
$id= isset( $_GET['id'] ) ? $_GET['id']:  0;

$modulname = "Penggajian _BN_ Pengecualian";
if($_SERVER["REQUEST_METHOD"] == "POST" ){
	if($task == 'edit_pengecualian_page'){
		$karyawan_id = check_karyawan_by_nik_nama($_POST['nama_karyawan']);
		if($id > 0  )
			update_pengecualian_submit($yearly_income_id,$id ,$karyawan_id);
		else
			submit_pengecualian($yearly_income_id,$karyawan_id , $_POST['komponen_id']);
		$content = "Updated!";
		generate_my_web($content , $pagename ,'plain.php');
		exit;
	}elseif($task == 'upload_pengecualian_page'){
		$n = upload_exception();
		$content = "Updated sebanyak {$n} data";
		generate_my_web($content , $pagename ,'plain.php');
		exit;
	}
}else{

	if($task == 'upload_pengecualian'){
			$title=  "Upload Data"  ;
			facebox_page('index.php?com='.$_GET['com'].'&task=upload_pengecualian_page&id='.$id , $title , 245	); 
	}elseif($task == 'edit_pengecualian'){
			$title=  "Ubah Data"  ;
			facebox_page('index.php?com='.$_GET['com'].'&task=edit_pengecualian_page&id='.$id , $title , 245	); 
	}elseif($task == 'upload_pengecualian_page'){
		$pagename="";
		$content = form_upload_pengecualian();
		generate_my_web($content , $pagename ,'plain.php');
		exit;
	}elseif($task == 'edit_pengecualian_page'){
		$pagename="";
		$content = form_pengecualian($yearly_income_id, $id);
		generate_my_web($content , $pagename ,'plain.php');
		exit;
	}elseif($task == 'delete'){ 
		delete_pengecualian($id);
		my_direct('index.php?com='.$_GET['com']);
	}elseif($task == "plaincetak"){
		@ob_end_clean(); 
		echo'<pre>';
		echo print_plain();
		exit;
	}elseif($task == "excel"){
		header("Content-Type: application/xls");
		header("Content-Disposition: attachment;filename=pengecualian_".rand().".xls");
		echo excel_report();
		exit;		
	}else{
		$pagename = $modulname ;
		load_facebox_script();	
		$view = list_adjustment($yearly_income_id);
	}
}	
generate_my_web($view, $pagename );

?>

